#include<bits/stdc++.h>
using namespace std;
#define int long long
int t,n,m,L,V,d[100001],v[100001],a[100001],p[100001],cnt;
struct node
{
	int l,r;
}seg[100001];
int check(int now,int aa,int vv)
{
	if(vv*vv+2*aa*now<=0) return 0;
	return vv*vv+2*aa*now;
}
bool cmp(node a,node b)
{
	if(a.l==b.l) return a.r<b.r;
	return a.l<b.l;
}
signed main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	while(t--)
	{
		cin>>n>>m>>L>>V;cnt=0;
		for(int i=1;i<=n;i++) cin>>d[i]>>v[i]>>a[i];
		for(int i=1;i<=m;i++) cin>>p[i];
		p[m+1]=1e9;
		for(int i=1;i<=n;i++)
		{
			int l=0,r=m;
			if(a[i]==0)
			{
				if(v[i]<=V) continue;
				l=lower_bound(p+1,p+m+2,d[i])-p;
				if(l==m+1) continue;
			}
			else if(a[i]>0)
			{
				int ll=0,rr=L-d[i],res=0;
				while(ll<=rr)
				{
					int mid=ll+rr>>1;
					if(check(mid,a[i],v[i])<=V*V) ll=mid+1;
					else rr=mid-1,res=mid;
				}
				if(res)
				{
					l=lower_bound(p+1,p+m+2,res+d[i])-p;
					if(l==m+1) continue;
				}
				else continue;
				//cout<<d[i]+res<<"\n";
			}
			else
			{
				int ll=0,rr=L-d[i],res=0;
				if(v[i]<=V) continue;
				while(ll<=rr)
				{
					int mid=ll+rr>>1;
					if(check(mid,a[i],v[i])<=V*V) rr=mid-1;
					else ll=mid+1,res=mid;
				}
				if(res)
				{
					l=lower_bound(p+1,p+m+2,d[i])-p;
					r=lower_bound(p+1,p+m+2,res+d[i])-p;
					r--;
				}
				else continue;
				if(l>r) continue;
				//cout<<d[i]+res<<"\n";
			}
			cnt++;seg[cnt].l=l,seg[cnt].r=r;
			//cout<<l<<" "<<r<<"\n";
		}
		cout<<cnt<<" ";
		sort(seg+1,seg+cnt+1,cmp);
		int ans=0,maxn=0;
		for(int i=1;i<=cnt;i++)
		{
			if(maxn<seg[i].l) ans++,maxn=seg[i].r;
		}
		cout<<m-ans<<"\n";
	}
	return 0;
}
